// Shader Parameters
float4x4	gMVP	: WORLDVIEWPROJECTION;

float2	gTexCoord[4];
float4 gColorMask;

// Texture and it's sampler
texture2D	gTexture;
sampler2D	gSampler =
sampler_state
{
	Texture = <gTexture>;
    FILTER = MIN_MAG_MIP_LINEAR;
    AddressU = Wrap;
    AddressV = Wrap;
};

// Inputs
struct Vertex
{
	int		srcRectIndex	: TEXCOORD0;
	float3	position		: POSITION0;
};
struct PixelIn
{
	float4	position	: POSITION0;
	float2	texCoord	: TEXCOORD0;
};

// Vertex Shader
PixelIn VertShader(Vertex input)
{
	PixelIn output;

	output.position = mul(float4(input.position,1),gMVP);
	output.texCoord = gTexCoord[input.srcRectIndex] + .005f;

	return output;
}

// Pixel Shader
float4 PixShader(float2 texCoord : TEXCOORD0) : COLOR0
{
	float4 color = tex2D(gSampler,texCoord);

	if(color.a < .05f)
		discard;

	return color * gColorMask;
}



//////////////////////////////////////////
technique TexTechnique
{
	pass FirstPass
	{
		// request what vertex and pixel shader are to be used, this can change for each pass.
        VertexShader = compile vs_3_0 VertShader();
        PixelShader  = compile ps_3_0 PixShader();
		// Setting a few of the many D3D renderstates via the effect framework
		ShadeMode = GOURAUD; // smooth color interpolation across triangles
        FillMode = SOLID; // no wireframes, no point drawing.
		CullMode = CCW;
		AlphaBlendEnable = true;
	}
}